VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmORD110 
   BackColor       =   &H8000000D&
   Caption         =   "ORD110"
   ClientHeight    =   3870
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8520
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   ScaleHeight     =   3870
   ScaleWidth      =   8520
   StartUpPosition =   3  'Windows Default
   Begin MSAdodcLib.Adodc Adodc2 
      Height          =   330
      Left            =   6480
      Top             =   360
      Visible         =   0   'False
      Width           =   1920
      _ExtentX        =   3387
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "2.ACN"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   6495
      Top             =   30
      Visible         =   0   'False
      Width           =   1905
      _ExtentX        =   3360
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "1.ATP"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   0  'None
      Caption         =   "Frame1"
      Height          =   1530
      Left            =   315
      TabIndex        =   10
      Top             =   1530
      Width           =   7950
      Begin VB.TextBox txtCACOD 
         Height          =   288
         Left            =   6330
         TabIndex        =   20
         Top             =   1020
         Width           =   1395
      End
      Begin VB.TextBox txtPCCOD 
         Height          =   288
         Left            =   6360
         TabIndex        =   18
         Top             =   585
         Width           =   1395
      End
      Begin MSDataListLib.DataCombo cboCNCID 
         Bindings        =   "frmORD110.frx":0000
         Height          =   345
         Left            =   1935
         TabIndex        =   17
         Top             =   1020
         Width           =   2955
         _ExtentX        =   5212
         _ExtentY        =   609
         _Version        =   393216
         ListField       =   "CNONM"
         BoundColumn     =   "CNCID"
         Text            =   ""
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "VNI-Times"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin VB.TextBox txtTPBAC 
         Height          =   288
         Left            =   6285
         TabIndex        =   15
         Top             =   120
         Width           =   1395
      End
      Begin VB.TextBox txtTPDSC 
         Enabled         =   0   'False
         Height          =   345
         Left            =   1935
         Locked          =   -1  'True
         MultiLine       =   -1  'True
         TabIndex        =   14
         Top             =   525
         Width           =   2715
      End
      Begin VB.TextBox txtTPCOD 
         Height          =   288
         Left            =   1920
         TabIndex        =   13
         Top             =   120
         Width           =   1008
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Company"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   8
         Left            =   210
         TabIndex        =   22
         Top             =   1095
         Width           =   1110
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Account Code"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   7
         Left            =   4950
         TabIndex        =   21
         Top             =   1065
         Width           =   1245
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Profit Center"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   6
         Left            =   4920
         TabIndex        =   19
         Top             =   630
         Width           =   1245
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Bank Account"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   4
         Left            =   4890
         TabIndex        =   16
         Top             =   165
         Width           =   1245
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Payment type code"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   5
         Left            =   180
         TabIndex        =   12
         Top             =   135
         Width           =   1785
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Description"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   3
         Left            =   180
         TabIndex        =   11
         Top             =   555
         Width           =   1110
      End
   End
   Begin VB.CommandButton cmdDelete 
      Caption         =   "&Delete"
      Height          =   372
      Left            =   5160
      TabIndex        =   7
      Top             =   3225
      Width           =   960
   End
   Begin VB.CommandButton cmdAddnew 
      Caption         =   "&New"
      Height          =   372
      Left            =   930
      TabIndex        =   4
      Top             =   3240
      Width           =   996
   End
   Begin VB.CommandButton cmdEdit 
      Caption         =   "&Edit"
      Height          =   372
      Left            =   1995
      TabIndex        =   3
      Top             =   3225
      Width           =   948
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "&Save"
      Height          =   372
      Left            =   3030
      TabIndex        =   2
      Top             =   3225
      Width           =   984
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "&Cancel"
      Height          =   372
      Left            =   4065
      TabIndex        =   1
      Top             =   3225
      Width           =   1032
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "&Exit"
      Height          =   372
      Left            =   6180
      TabIndex        =   0
      Top             =   3225
      Width           =   1080
   End
   Begin MSDataListLib.DataCombo cboTPCOD 
      Bindings        =   "frmORD110.frx":0015
      Height          =   285
      Left            =   3750
      TabIndex        =   8
      Top             =   1110
      Width           =   2250
      _ExtentX        =   3969
      _ExtentY        =   556
      _Version        =   393216
      ListField       =   "TPDSC"
      BoundColumn     =   "TPCOD"
      Text            =   ""
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Select Type Of Payment"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0080FFFF&
      Height          =   225
      Index           =   2
      Left            =   1485
      TabIndex        =   9
      Top             =   1155
      Width           =   2145
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "ORD110"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   -1  'True
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   465
      Index           =   0
      Left            =   45
      TabIndex        =   6
      Top             =   30
      Width           =   1770
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Type Of Payment"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   16.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   495
      Index           =   1
      Left            =   2115
      TabIndex        =   5
      Top             =   525
      Width           =   3480
   End
End
Attribute VB_Name = "frmORD110"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim OldTPCOD As String
Private Sub WriteToFile()
Dim SQLInsert As String
If ISADDING Then
    SQLInsert = " INSERT INTO ATP " & _
                  "(TPCOD,TPDSC,TPBAC,CNCID,PCCOD,CACOD) " & _
                "VALUES " & _
                  "('" & txtTPCOD & "', '" & txtTPDSC & "','" & txtTPBAC & "','" & txtCNCID & "','" & txtPCCOD & "','" & txtCACOD & "')"
 Else
    SQLInsert = "UPDATE ATP SET TPCOD = '" & txtTPCOD & "', TPDSC ='" & txtTPDSC & "' " & _
                ",TPBAC='" & txtTPBAC & "',CNCID='" & txtCNCID & "'" & _
                ",PCCOD='" & txtPCCOD & "',CACOD='" & txtCACOD & "'" & _
                " WHERE TPCOD ='" & OldTPCOD & "'"
End If

DBconn.Execute SQLInsert

End Sub

Private Sub WriteToScreen()
If ISADDING Then 'gan rong
        txtTPCOD = ""
        txtTPDSC = ""
        txtTPBAC = ""
        cboCNCID.BoundText = ""
        txtPCCOD = ""
        txtCACOD = ""
Else
        Dim TBL As ADODB.Recordset
        Set TBL = New ADODB.Recordset
        TBL.Open "  Select ATP.* From ATP where  TPCOD ='" & cboTPCOD.BoundText & "'", DBconn, adOpenKeyset, adLockOptimistic, adCmdText
        If TBL.EOF = False Then
            txtTPCOD = IIf(IsNull(TBL!TPCOD), "", TBL!TPCOD)
            txtTPDSC = IIf(IsNull(TBL!TPDSC), "", TBL!TPDSC)
            txtTPBAC = IIf(IsNull(TBL!TPBAC), "", TBL!TPBAC)
            cboCNCID.BoundText = IIf(IsNull(TBL!CNCID), "", TBL!CNCID)
            txtPCCOD = IIf(IsNull(TBL!PCCOD), "", TBL!PCCOD)
            txtCACOD = IIf(IsNull(TBL!CACOD), "", TBL!CACOD)
        Else
            txtTPCOD = ""
            txtTPDSC = ""
            txtTPBAC = ""
            cboCNCID.BoundText = ""
            txtPCCOD = ""
            txtCACOD = ""
        End If
        TBL.Close
End If
OldTPCOD = txtTPCOD
End Sub

Sub ButtonStatus()
cmdAddNew.Enabled = Not ISEDITING
cmdEdit.Enabled = Not ISEDITING
cmdSave.Enabled = ISEDITING ' And txtIMITN <> ""
cmdDelete.Enabled = Not ISEDITING 'And txtIMITN <> ""
cmdCancel.Enabled = ISEDITING
Frame1.Enabled = ISEDITING
'txtIMITN.Locked = Not ISADDING ' Lock item code tru truong hop ISADDING=true
'txtDepartment.Enabled = ISEDITING
'cboDepartment.Visible = Not ISADDING
'txtDepartmentID.Visible = ISADDING
End Sub

Private Sub cboCNCID_Click(Area As Integer)
If Area = 2 Then
    txtCACOD.SetFocus
End If
End Sub

Private Sub cboTPCOD_Click(Area As Integer)
If Area = 2 Then
    WriteToScreen
End If


End Sub

Private Sub cmdAddnew_Click()
ISADDING = True
ISEDITING = True
WriteToScreen

' Ham Gan tri man hinh
ButtonStatus

End Sub

Private Sub cmdCancel_Click()
' Gan tri man nhinh
ISADDING = False
ISEDITING = False

ButtonStatus
txtTPCOD = cboTPCOD.BoundText
WriteToScreen


End Sub

Private Sub cmdDelete_Click()
Dim SQL As String
SQL = "DELETE FROM ATP WHERE TPCOD = '" & cboTPCOD.BoundText & "'"

Set cmdExecute = New ADODB.Command
Set cmdExecute.ActiveConnection = DBconn
cmdExecute.CommandText = SQL
cmdExecute.Execute
Adodc1.Refresh
'WriteToScreen (0)

End Sub

Private Sub cmdEdit_Click()
ISEDITING = True
' Ham gan tri man hinh
ISADDING = False
ISEDITING = True


ButtonStatus

End Sub

Private Sub cmdExit_Click()
Unload frmORD110
End Sub

Private Sub cmdSave_Click()


WriteToFile
Adodc1.Refresh

'''''''''''
ISADDING = False
ISEDITING = False

ButtonStatus


End Sub

Private Sub Form_Load()
'BIENCHUNG
Adodc1.ConnectionString = ConnectString
Adodc1.ConnectionTimeout = 10
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "ATP" 'SALEMAN
Adodc1.Refresh

Adodc2.ConnectionString = ConnectString
Adodc2.ConnectionTimeout = 10
Adodc2.CommandType = adCmdTable
Adodc2.RecordSource = "ACN" 'Company
Adodc2.Refresh
ISADDING = False
ISEDITING = False
ButtonStatus

End Sub

Private Sub txtPCCOD_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    cboCNCID.SetFocus
End If
End Sub

Private Sub txtTPBAC_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    txtPCCOD.SetFocus
End If
End Sub

Private Sub txtTPCOD_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    If ValidMaso(OldTPCOD, txtTPCOD, "ATP", " TPCOD='" & txtTPCOD & "'") Then
        MsgBox "This code is already exist"
        txtTPCOD.SetFocus
    Else
        txtTPDSC.SetFocus
    End If
End If
End Sub

Private Sub txtTPDSC_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    txtTPBAC.SetFocus
End If
End Sub
